package com.fsnbigdata.repository;
import io.springlets.data.jpa.repository.support.QueryDslRepositorySupportExt;
import org.springframework.roo.addon.layers.repository.jpa.annotations.RooJpaRepositoryCustomImpl;
import com.fsnbigdata.domain.ParkDistrictOrganismImage;
import com.fsnbigdata.domain.ParkDistrictOrganism;
import com.fsnbigdata.domain.QParkDistrictOrganismImage;
import com.querydsl.core.types.Path;
import com.querydsl.jpa.JPQLQuery;
import io.springlets.data.domain.GlobalSearch;
import io.springlets.data.jpa.repository.support.QueryDslRepositorySupportExt.AttributeMappingBuilder;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;

/**
 * = ParkDistrictOrganismImageRepositoryImpl
 *
 * TODO Auto-generated class documentation
 *
 */
@RooJpaRepositoryCustomImpl(repository = ParkDistrictOrganismImageRepositoryCustom.class)
@Transactional(readOnly = true)
public class ParkDistrictOrganismImageRepositoryImpl extends QueryDslRepositorySupportExt<ParkDistrictOrganismImage> implements ParkDistrictOrganismImageRepositoryCustom {

    /**
     * TODO Auto-generated constructor documentation
     */
    ParkDistrictOrganismImageRepositoryImpl() {
        super(ParkDistrictOrganismImage.class);
    }

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    public static final String LOCATION = "location";

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    public static final String CODE = "code";

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    public static final String CREATE_DATE = "createDate";

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    public static final String PARK_DISTRICT_ORGANISM = "parkDistrictOrganism";

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    public static final String DESCRIPTION = "description";

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    public static final String AUTHOR = "author";

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    public static final String URL = "url";

    /**
     * TODO Auto-generated method documentation
     *
     * @param parkDistrictOrganism
     * @param globalSearch
     * @param pageable
     * @return Page
     */
    public Page<ParkDistrictOrganismImage> findByParkDistrictOrganism(ParkDistrictOrganism parkDistrictOrganism, GlobalSearch globalSearch, Pageable pageable) {
        QParkDistrictOrganismImage parkDistrictOrganismImage = QParkDistrictOrganismImage.parkDistrictOrganismImage;
        JPQLQuery<ParkDistrictOrganismImage> query = from(parkDistrictOrganismImage);
        Assert.notNull(parkDistrictOrganism, "parkDistrictOrganism is required");
        query.where(parkDistrictOrganismImage.parkDistrictOrganism.eq(parkDistrictOrganism));
        Path<?>[] paths = new Path<?>[] { parkDistrictOrganismImage.parkDistrictOrganism, parkDistrictOrganismImage.code, parkDistrictOrganismImage.description, parkDistrictOrganismImage.location, parkDistrictOrganismImage.author, parkDistrictOrganismImage.url, parkDistrictOrganismImage.createDate };
        applyGlobalSearch(globalSearch, query, paths);
        AttributeMappingBuilder mapping = buildMapper().map(PARK_DISTRICT_ORGANISM, parkDistrictOrganismImage.parkDistrictOrganism).map(CODE, parkDistrictOrganismImage.code).map(DESCRIPTION, parkDistrictOrganismImage.description).map(LOCATION, parkDistrictOrganismImage.location).map(AUTHOR, parkDistrictOrganismImage.author).map(URL, parkDistrictOrganismImage.url).map(CREATE_DATE, parkDistrictOrganismImage.createDate);
        applyPagination(pageable, query, mapping);
        applyOrderById(query);
        return loadPage(query, pageable, parkDistrictOrganismImage);
    }
}
